function Iris
% 灵感来自 Oliver Brotherhood 的 Processing 作品 Iris
% 由 slandarer 使用 MATLAB 进行复刻
randPntNum=30;
tPntNum=3000;
tList=1:tPntNum;
% 生成连续随机角度
randList1=(rand(1,randPntNum)-.5).*2.*3.15;
randList2=(rand(1,randPntNum)-.5).*2.*3.15;
randList3=(rand(1,randPntNum)-.5).*2.*3.15;
thetaList1=interp1(linspace(1,tPntNum,randPntNum),randList1,tList,'makima');
thetaList2=interp1(linspace(1,tPntNum,randPntNum),randList2,tList,'makima');
thetaList3=interp1(linspace(1,tPntNum,randPntNum),randList3,tList,'makima');
% 渐变颜色
% #046380, #16193B, #35478C, #4E7AC7, #7FB2F0, #ADD5F7
CList=[4 99 128;22 25 59;53 71 140;78 122 199;127 178 240;173 213 247]./255;
ti=linspace(1,tPntNum,size(CList,1))';
CList=[interp1(ti,CList(:,1),tList,'linear')',...
       interp1(ti,CList(:,2),tList,'linear')',...
       interp1(ti,CList(:,3),tList,'linear')'];
% 坐标区域修饰
ax=gca;hold on
ax.XLim=[-1,1];
ax.YLim=[-1,1];
ax.XColor='none';
ax.YColor='none';
ax.DataAspectRatio=[1,1,1];
% 随机椭圆半径
A1=rand(1,1);B1=rand(1,1);
A2=rand(1,1);B2=rand(1,1);
for i=1:3000
    X=[0;A1*cos(thetaList1(i));A2*cos(thetaList2(i));cos(thetaList3(i))];
    Y=[0;B1*sin(thetaList1(i));B2*sin(thetaList2(i));sin(thetaList3(i))];
    bezierPnts=bezierCurve([X,Y],100);
    plot(bezierPnts(:,1),bezierPnts(:,2),'Color',[CList(i,:),.2],'LineWidth',.5)
    pause(.01)
end
% 贝塞尔函数
    function pnts=bezierCurve(pnts,N)
        t=linspace(0,1,N);
        p=size(pnts,1)-1;
        coe1=factorial(p)./factorial(0:p)./factorial(p:-1:0);
        coe2=((t).^((0:p)')).*((1-t).^((p:-1:0)'));
        pnts=(pnts'*(coe1'.*coe2))';
    end
end